package com.mbengue.corp.apr.ra.core;

import java.io.Serializable;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name = "lieuevenement", schema = "apr_ra")
@NamedQueries(value = {
    @NamedQuery(name = "findByEvenement", query = "SELECT le FROM LieuEvenement le WHERE le.evenement=:evenement"),
    @NamedQuery(name = "findByLieu", query = "SELECT le FROM LieuEvenement le WHERE le.adresse=:adresse") })
public class LieuEvenement implements Serializable {
  private static final long serialVersionUID = 1L;
  private LieuEvenementId id;
  private Adresse adresse;
  private Evenement evenement;

  @EmbeddedId
  @AttributeOverrides({
      @AttributeOverride(name = "idEvenement", column = @Column(name = "idEvenement", nullable = false)),
      @AttributeOverride(name = "idAdresse", column = @Column(name = "idAdresse", nullable = false)) })
  public LieuEvenementId getId() {
    return id;
  }

  public void setId(LieuEvenementId aId) {
    id = aId;
  }

  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "idAdresse", nullable = false, insertable = false, updatable = false)
  public Adresse getAdresse() {
    return adresse;
  }

  public void setAdresse(Adresse aAdresse) {
    adresse = aAdresse;
  }

  @OneToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "idEvenement", nullable = false, insertable = false, updatable = false)
  public Evenement getEvenement() {
    return evenement;
  }

  public void setEvenement(Evenement aEvenement) {
    evenement = aEvenement;
  }

  public LieuEvenement() {
    // TODO Auto-generated constructor stub
  }

  public LieuEvenement(LieuEvenementId aId, Adresse aAdresse, Evenement aEvenement) {
    super();
    id = aId;
    adresse = aAdresse;
    evenement = aEvenement;
  }
}
